package com.haircut.project.controller.group;

import com.haircut.project.dao.group.ProjectGroupMapper;
import com.haircut.project.service.group.IProjectGroupService;
import com.haircut.project.vo.finance.FinanceReqVo;
import com.haircut.project.vo.finance.FinanceResVo;
import com.haircut.project.vo.group.*;
import com.modular.result.PageResult;
import com.modular.result.RspMessage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/b/group")
public class ProjectGroupController {
    @Autowired
    private IProjectGroupService projectGroupService;
    /**
     * 查询下游部门
     * @return
     */
    @ApiOperation(value = "查询所有分组")
    @PostMapping("findAll")
    public RspMessage<List<GroupListResVo>> findAll(@RequestBody GroupListReqVo reqVo){
        return RspMessage.success(projectGroupService.findAll(reqVo));
    }
    /**
     * 查询下游部门
     * @return
     */
    @ApiOperation(value = "保存分组")
    @PostMapping("saveGroup")
    public RspMessage<Void> saveGroup(@Validated @RequestBody GroupSaveVo reqVo){
        projectGroupService.saveGroup(reqVo);
        return RspMessage.success();
    }
    /**
     * 查询下游部门
     * @return
     */
    @ApiOperation(value = "保存分组")
    @PostMapping("modifyGroup")
    public RspMessage<Void> modifyGroup(@Validated @RequestBody GroupSaveVo reqVo){
        projectGroupService.modifyGroup(reqVo);
        return RspMessage.success();
    }
    /**
     * 查询下游部门
     * @return
     */
    @ApiOperation(value = "删除分组")
    @GetMapping("delGroup")
    public RspMessage<Void> delGroup(@ApiParam("分组id") @RequestParam("groupId") String groupId){
        projectGroupService.delGroup(groupId);
        return RspMessage.success();
    }

    /**
     * 查询下游部门
     * @return
     */
    @ApiOperation(value = "保存分组")
    @PostMapping("batchSaveGroupConfigRel")
    public RspMessage<Void> batchSaveGroupConfigRel(@Validated @RequestBody BatchGroupConfigRelVo reqVo){
        projectGroupService.batchSaveGroupConfigRel(reqVo);
        return RspMessage.success();
    }

    /**
     * 查询下游部门
     * @return
     */
    @ApiOperation(value = "查询配置分组")
    @PostMapping("findGroupConfigPage")
    public RspMessage<PageResult<GroupConfigRelResVo>> findGroupConfigPage(@Validated @RequestBody GroupConfigReqVo reqVo){
        return RspMessage.success(projectGroupService.findGroupConfigPage(reqVo));
    }


}
